import mod_entity,mod_gui
from mod_effects import doAreaOfEffectDamage

class BarrelDestroyedEffect:
    def doIt(self,barrel,oldLocation):
        mod_gui.theGUI.messages.append('THE BARREL EXPLODES!')
        def damageFunction(distance):
            return int(round(15.0 - (5.0*distance)))
        doAreaOfEffectDamage(oldLocation,2,'MISC_EXPLOSION',damageFunction)

barrelPrototype = mod_entity.EntityPrototype('BARREL',maxHP=2)
barrelPrototype.deathEffect = BarrelDestroyedEffect()